 <template>
 	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap">
 		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
		 <div class="bt">修改</div>
 		<el-form label-width="100px" class="form">
 			<el-form-item label="节假日名称">
 				<el-input v-model="form.jjrmc" disabled  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			 <el-form-item label="节假日日期">
 				<el-input v-model="form.rq" :readonly='true' disabled  placeholder="请输入" class="select-block"></el-input>
 				<span style="color: red;">注：若想修改节假日日期，请删除后重新添加</span>
            <!--<el-date-picker v-model="vrq1" type="date" placeholder="开始日期" @keyup.enter.native="search" icon="search" style='width: 42%;float: left;'></el-date-picker>-->
		 	<!--<el-date-picker v-model="vrq2" type="date" placeholder="结束日期" @keyup.enter.native="search" icon="search" style='width: 42%;float: left;'></el-date-picker>-->
 		    <!--<span style="color: red;float: left;">注：添加或修改节假日，将会自动影响全校课表的变化</span>-->
 			</el-form-item>
 			<el-form-item label="说明">
 				<el-input v-model="form.sm" type="textarea" :rows="4" placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 		</el-form>
 		<div class="an" style="text-align: center;">
		<el-button type="primary" class="submit" @click="submit">添加</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
		</div>
 	</el-dialog>
 </template>
 <script type="text/javascript">
 	import qs from 'qs'
 	export default {
 		props: ['params'],
 		data() {
 			return {
 				vrq1:'',
 				vrq2:'',
 				form: {
           jjrmc :'',
           rq :'',
           sm :'',
           rq2:'',
 					 id:''
 				}
 			}
 		},
 		created() {

  		 this.form.id = this.params.row.id;
 	    // this.form.rq ='2001-01-01--2019-01-02'; //this.params.row.rq;


 			  this.loadinfo();

 		},
 		methods: {
 			loadinfo(){
 				var logininfo = JSON.parse(localStorage.logininfo);
             var params2 = qs.stringify({
                  xxid:logininfo.xxid,
 							 yhid:logininfo.id,
 							 id:this.form.id
               })
             //执行
                 this.axios.post(this.$store.state.api + 'jjr/info',  params2 )
                 .then(res => {
                 this.form=res.data.data
                 }).catch(res => {
					this.$message.warning("服务器异常");
 			 				this.$emit('close', { type: 'info', cancel: true });
				})
 			},
 			selectedtime(){
 			    var time1 = this.$.getLocalTimeNo0(Date.parse(this.vrq[0]));
				var time2 = this.$.getLocalTimeNo0(Date.parse(this.vrq[1]));
				var time3 = (time1+"--"+time2)

				this.form.rq = time3;
 			},
 			 submit() {
 				//检测
 				this.$store.state.loading = true;
 				var time1 = this.$.getLocalTimeNo0(Date.parse(this.vrq1));
				var time2 = this.$.getLocalTimeNo0(Date.parse(this.vrq2));
				var time3 = (time1+"--"+time2)
 				var logininfo = JSON.parse(localStorage.logininfo);
 				var params2 = qs.stringify({
 						id: this.form.id,
 						jjrmc: this.form.jjrmc,
 						rq: time3,
 						sm: this.form.sm,
 						yhid: logininfo.id,
 						xxid: logininfo.xxid
 					})
 				//执行
 				    this.axios.post(this.$store.state.api + 'jjr/update',  params2 )
 						.then(res => {
 							if(res.data.code == 1) {
 								this.$emit('close', { type: 'edit', cancel: false });
 								this.$message.success(res.data.msg);
 								this.$store.state.loading = false;
 							} else {
 								this.$message.warning(res.data.msg);
 								this.$store.state.loading = false;
 							}
 						}).catch(res => {
 							this.$message.danger("服务器异常");
 							this.$store.state.loading = false;
 						})
 			},
 			cancel() {
 				this.$emit('close', { type: 'edit', cancel: true })
 			}
 		}
 	}
 </script>
 <style lang="less" scoped>
 	.wrap {
 		text-align: center;
 	}
 	.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
 	.form {
 		text-align: left;
 		margin-top: 20px;
 	}
 	.input {
             display: inline-block;
         }
 	.select-block {
 		display: block;
 		width: 85%;
 	}
 	.submit {
 		width: 120px;
 	}
 </style>
